<template>
	<view class="content">
		<image src="/static/tabbar/index/success.png" mode="aspectFill" class="scimg"></image>

		<view class="scr">
			<view class="fs18 colorFF6 font-weight text-center">订单提交成功</view>
			<view class="mt2"><text class="fs14 color9">订单号：</text><text class="fs16 color3 font-weight">{{orderid}}</text></view>
			<view class="mt2"><text class="fs14 color9">配送时间：</text><text class="fs16 color3 font-weight">{{DeliveryDate}}</text></view>
			<view class="mt2"><text class="fs14 color9">订单金额：</text><text class="fs16 colorm font-weight">￥{{payamount.toFixed(2)}}</text></view>
		</view>
		<navigator :url="'/pages/order-detail/order-detail?id='+orderid" open-type="navigate">
			<view class="colorf fs16 text-center qued">查看订单</view>
		</navigator>
		<navigator url="/pages/tabBar/index" open-type="switchTab">
			<view class="colorf fs16 text-center qued goback">回到首页</view>
		</navigator>
	</view>
</template>

<script>
	import {
		request
	} from '@/api/request/index.js'
	import local_userinfo from '@/util/user/local-userinfo.js'
	import date_parse from '@/util/date/date-parse.js'
	//用户缓存信息
	let userSession = local_userinfo.getUserinfo();
	export default {
		data() {
			return {
				orderid: '',
				payamount: 0,
				DeliveryDate: ''
			};
		},
		onLoad: function(options) {
			var that = this;
			if (options.orderid) {
				userSession = local_userinfo.getUserinfo();
				that.orderid = options.orderid;
				request.get({
						data: {
							c: 'UserOrderController',
							m: 'OrderDetails',
							pageno: 1,
							rediskey: userSession.sessionid,
							orderid: options.orderid
						}
					})
					.then(res => {
						console.log(res)
						if (res.Status == "ok") {
							res.Tag.map((item) => {
								item.orderitem.DeliveryDate = date_parse.jsonDateToDateString(item.orderitem.DeliveryDate) + ' ' + item.orderitem
									.DeliveryTimeBegin + '-' + item.orderitem.DeliveryTimeEnd;
								// item.orderitem.OrderDate=date_parse.jsonDateToDateTimeString(item.orderitem.OrderDate);
								// item.orderitem.paynow=false;
								// let paystatus=item.orderitem.PayStatus;
								// let orderstatus=item.orderitem.OrderStatus;
								// if(paystatus=='未支付'&&(orderstatus!=="已作废" && orderstatus!=="拒收")){ item.orderitem.paynow=true;item.orderitem.OrderStatus="待付款";}
								that.DeliveryDate = item.orderitem.DeliveryDate;
								that.payamount = item.orderitem.PayableAmount;
							})

						} else {
							uni.showModal({
								title: res.Msg,
								showCancel: false
							})
						}
					})
					.catch(error => {
						console.error(error)

					});
			}
			// #ifdef MP-WEIXIN
			uni.hideShareMenu()
			// #endif
		}
	}
</script>

<style lang="scss">
	.content {
		.scimg {
			width: 25vw;
			height: 25vw;
			display: block;
			margin: 20vw auto 5vw auto;
		}

		.mt2 {
			margin-top: 2vw;
		}

		.scr {
			width: 75vw;
			margin: 0 auto;
		}

		.qued {
			background: #00449F;
			height: 12vw;
			line-height: 12vw;
			width: 50vw;
			margin: 0 auto;
			border-radius: 6vw;
			margin-top: 10vw;
		}

		.goback {
			background: none;
			color: #666;
			margin-top: 2vw;
		}
	}
</style>
